﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<string>" %>
<div class="scrollbox" style="max-width:488px">
<ul data-bind="foreach: availableFeatures" id="vmFeature">
    <li  data-bind="css: { 'odd': ($index() % 2 != 0) }">
        <input type="checkbox" data-bind="attr: { value: Features_ID }, checked: $root.selectedFeature"  name="Features"><span data-bind="text: Features"></span>
    </li>
</ul>
 </div>
<script type="text/javascript">
    $(document).ready(function() {
        var selected = [""];
        <% if(Model.ToString()!=""){
         %>
            selected =[<%=Model.ToString()%>];
         <%}  %>
        System.Data.Features = function() {
            var self = this;
           
            self.availableFeatures = ko.observableArray([]);
            self.selectedFeature = ko.observableArray(selected);
            //load
            (function() {
                $.getJSON(BASE_URL + "Listings/Ajax/GetFeature", function(result) {
                    self.availableFeatures(result.Data);

                });
            })();
        }
        //
        var vmFeature = new System.Data.Features();
        ko.applyBindings(vmFeature, $("#vmFeature")[0]);
       
    });
</script>